      
        /* 客户管理-新增-选择客户 */
        function selectUserInfo_oppositor(idx) {
        	$("#oppositor_cur_idx").val("mytext");
        	$("#oppositor_cur_idx").val(idx);
        	var url = ctx + "crm/custinfo/choice";
			var options = {
				title: '选择客户',
				width: "840",
				height: "560",
				url: url,
				callBack: doSubmitUserInfo_oppositor
			};
			$.modal.openOptions(options);
		}
        
        /* 选择客户后，进行相应的赋值 */
		function doSubmitUserInfo_oppositor(index, layero) {
			var body = $.modal.getChildFrame(index);
			var cur_idx = $("#oppositor_cur_idx").val();
			/* set val */
			var caseCustType_n = $.common.sprintf('#oppositor_%s_caseCustType', cur_idx);
			var caseCustIndex_n = $.common.sprintf('#oppositor_%s_caseCustIndex', cur_idx);
			var custId_n = $.common.sprintf('#oppositor_%s_custId', cur_idx);
			var custName_n = $.common.sprintf('#oppositor_%s_custName', cur_idx);
			var certNo_n = $.common.sprintf('#oppositor_%s_certNo', cur_idx);
			var custType_n = $.common.sprintf('#oppositor_%s_custType', cur_idx);
			
			let caseCustType = 2;
			let caseCustIndex = cur_idx;
			let custId = body.find('#custId').val();
			let custName = body.find('#custName').val();
			let certNo = body.find('#certNo').val();
			let custType = body.find('#custType').val();

   			$(caseCustType_n).val(String(caseCustType));
   			$(caseCustIndex_n).val(String(caseCustIndex));
   			$(custId_n).val(custId);
   			$(custName_n).val(custName);
   			$(certNo_n).val(certNo);
   			$(custType_n).val(custType);

			var custSelect_n = $.common.sprintf('#custSelect_oppositor_%s', cur_idx);
			var cs_val = $.common.sprintf('(%s-%s-%s-%s)', custId, custName, certNo, custType);
			$(custSelect_n).val(cs_val);
   			$.modal.close(index);
		}

        /* 用户管理-新增-选择部门树 */
        function deleteRow_oppositor(idx) {
        	var lsoppositorId_n = "div_oppositor_" + idx;
        	var x = document.getElementById(lsoppositorId_n);
        	//如果对象x不为空
        	if (x != null) {
        	    x.remove();
        	}
        	deleteRow_oppositor_after4();
        	/* deleteRow_oppositor_after(); */
		}
        
        function deleteRow_oppositor_after() {
        	var nods = document.getElementsByName('div_oppositor');
        	for (let index=0; index < nods.length; index++) {
        		  let elem = nods[index];
        		  elem.id = 'div_oppositor_' + ((index+1) *10);
        		  var lsIndex = document.getElementsByName("div_oppositor_index");
        		  if (lsIndex.length > 0) {
        			  //for (let i=0; i < lsIndex.length; i++) {
        				  let oDiv = lsIndex[0];
        			  //}
            		  oDiv.innerText = (i+1) * 10;
        		  }
        	}
        }

        function deleteRow_oppositor_after4() {
        	deleteRow_oppositor_after_div();
        	deleteRow_oppositor_after_input();
        }

        function deleteRow_oppositor_after_div() {
        	var nods = document.getElementsByName('div_oppositor');
        	for (let j=0; j < nods.length; j++) {
        		let c = nods[j];
  			  	if (c != null) {
      			  let cName = c.getAttribute("name");
      			  if (cName != null) {
					c.id = c.id.replace(/\d/g, String(j));
      				let ls_div_fld = c.children;
          		  	for (let k=0; k < ls_div_fld.length; k++) {
	          			let c_fld = ls_div_fld[k];
	          			if (c_fld != null) {
	          				let c_fld_name = c_fld.getAttribute("name");
	          				if (c_fld_name != '') {
	          					if (c_fld_name=='div_oppositor_index') {
	          						const str = c_fld.innerText;
	          						const regex = /\d/g;
	          						let replacedStr = str.replace(regex, String(j+1));
	          						c_fld.innerText = replacedStr;
	          					}
	          				}
	          			}
          		  	}
      			  }
  			  }
        	}
        }

        function deleteRow_oppositor_after_input() {
        	var nods = document.getElementsByName('div_oppositor_input');
        	for (let j=0; j < nods.length; j++) {
        		let c = nods[j];
  			  	if (c != null) {
      			  let cName = c.getAttribute("name");
      			  if (cName != null) {
      				let ls_div_fld = c.children;
          		  	for (let k=0; k < ls_div_fld.length; k++) {
	          			let c_fld = ls_div_fld[k];
	          			if (c_fld != null) {
	          				let c_fld_name = c_fld.getAttribute("name");
	          				if (c_fld_name != '') {
	          					if (c_fld_name=='custSelect') {
	          						const str = c_fld.id;
	          						const regex = /\d/g;
	          						let replacedStr = str.replace(regex, String(j));
	          						c_fld.id = replacedStr;
	          					} else if (c_fld_name=='selectUserInfo') {
	          						const str = c_fld.getAttribute("onclick");
	          						const regex = /\d/g;
	          						let replacedStr = str.replace(regex, String(j));
	          						c_fld.setAttribute("onclick", replacedStr);
	          					} else if (c_fld_name=='deleteRow') {
	          						const str = c_fld.getAttribute("onclick");
	          						const regex = /\d/g;
	          						let replacedStr = str.replace(regex, String(j));
	          						c_fld.setAttribute("onclick", replacedStr);
	          					} else if (c_fld_name.indexOf(".")!=-1) {
									/* id */
	          						var str = c_fld.id;
	          						const regex = /\d/g;
	          						var replacedStr = str.replace(regex, String(j));
	          						c_fld.id = replacedStr;
	          						/* name */
	          						replacedStr = c_fld_name.replace(regex, String(j));
	          						c_fld.setAttribute("name", replacedStr);
	          					}
	          				}
	          			}
          		  	}
      			  }
  			  }
        	}
        }
        
        function deleteRow_oppositor_after_after5() {
        	var nods = document.getElementsByName('div_oppositor');
        	for (let index=0; index < nods.length; index++) {
        		  let elem = nods[index];
        		  /* alert(elem.innerHTML); */
        		  elem.id = 'div_oppositor_' + ((index+1) *10);
        		  let ls_div = elem.children;
        		  for (let j=0; j < ls_div.length; j++) {
        			  let c = ls_div[j];
        			  if (c != null) {
	        			  let cName = c.getAttribute("name");
	        			  if (cName != null) {
			        		  if (cName == 'div_oppositor_index') {
			        			  c.innerText = String((index+1) *10);
			        		  } else if (cName == 'div_oppositor_col_sm') {
		        				  let ls_div_col_sm = c.children;
		                		  for (let k=0; k < ls_div_col_sm.length; k++) {
		                			  let c_col_sm = ls_div_col_sm[k];
		                			  if (c_col_sm != null) {
		                				  let col_sm_Name = c_col_sm.getAttribute("name");
		        	        			  if (col_sm_Name != null) {
		        	        				if (col_sm_Name== 'div_oppositor_input') {
		        	        					let ls_input = elem.children;
		        	        	        		for (let l=0; l < ls_input.length; l++) {
		        	        	        			let c_input = ls_input[l];
		        	        	        			console.log(c_input.innerHTML);
		        	        	        			if (c_input != null) {
		        	        	        				let c_input_name = c_input.getAttribute("name");
		        	        	        			}
		        	        	        		}
		        	        				}
		        	        			  }
		                			  }
		                		  }
		        			  }
	        			  }
        			  }
        		  }
        	}
        }
             
        /* 客户管理-新增-选择客户 */
        function addRow_oppositor() {
        	var idx = 0;
        	var nods = document.getElementsByName('div_oppositor');
        	if (nods.length>0) {
        		idx = nods.length;
            	var str = getAddRow_oppositor(idx, idx);
            	var node = document.getElementById('div_oppositor_body');
            	node.insertAdjacentHTML('beforeend', str);
        	} else {
        		idx = 0;
            	var str = getAddRow_oppositor(idx, idx);
            	var node = document.getElementById('div_oppositor_body');
            	node.insertAdjacentHTML('beforeend', str);
        	}
        }
        
        /* 客户管理-新增-选择客户 */
        function addRow_oppositor_empty() {
        	var idx = 0;
           	var str = getAddRow_oppositor(idx, idx);
        	var node = document.getElementById('div_oppositor_body');
           	node.insertAdjacentHTML('beforeend', str);
        }

        /* 客户管理-新增-选择客户 */
        function addRow_oppositor1() {
        	var idx = 0;
        	var nods = $('[name="div_oppositor"]');
        	idx = nods.length;
        	var str = getAddRow_oppositor(idx, idx);
        	var node = nods[nods.length - 1];
        	node.insertAdjacentHTML('beforeend', str);
        }
        	
        function getAddRow_oppositor(sortNo, index) {
        	let tr = `
        	  <div name="div_oppositor" id="div_oppositor_${index}">
                <label class="col-sm-3 control-label is-required" name="div_oppositor_index">利益相对方: ${sortNo+1}</label>
                <div class="col-sm-8" name="div_oppositor_col_sm">
                  <div class="input-group">
						<div class="input-group">
  							<input type="hidden" name="oppositor[${index}].caseCustIndex" id="oppositor_${index}_caseCustIndex" value="${index}"/>
      						<input type="hidden" name="oppositor[${index}].caseCustType" id="oppositor_${index}_caseCustType" value="2"/>
          					<input type="hidden" name="oppositor[${index}].custId" id="oppositor_${index}_custId"/>
          					<input type="hidden" name="oppositor[${index}].custName" id="oppositor_${index}_custName"/>
              				<input type="hidden" name="oppositor[${index}].certNo" id="oppositor_${index}_certNo"/>
                  			<input type="hidden" name="oppositor[${index}].custType" id="oppositor_${index}_custType"/>
						</div>
                    	<input name="custSelect" id="custSelect_oppositor_${index}" type="text" placeholder="请选择客户" class="form-control" 
                    	  readonly>
                    	<span name="selectUserInfo" class="input-group-addon" onclick="selectUserInfo_oppositor(${index})"><i class="fa fa-search"></i></span>
                    	<span name="deleteRow" class="input-group-addon" onclick="deleteRow_oppositor(${index})"><i class="fa fa-minus"></i></span>
                  </div>
                </div>
                </span>
                </span>
               </div>
        	   `
        			
        	return tr;
        }
    